layui.define([ 'form', 'laydate', 'table','industrialTalentsApi'], function(exports) {
    var form = layui.form;
    var industrialTalentsApi = layui.industrialTalentsApi;
    var index = layui.index;
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                 form.on('submit(form)', function() {
                     /**
                      * 获取身份证文件
                      */

                     var isEmpty = Common.fileRequire("#IdfileDataList");
                     var payList = Common.fileRequire("#payListDataList");
                     var taxProof = Common.fileRequire("#taxProofDataList");
                     var bankCardNumberProve = Common.fileRequire("#bankCardNumberProveDataList");
                   //  var laborContract = Common.fileRequire("laborContractDataList");

                     if (isEmpty) {
                         Common.alert("身份证件附件必须上传");
                     }else if (payList) {
                         Common.alert("纳税清单附件必须上传");
                     }else if (taxProof) {
                         Common.alert("完税证明附件必须上传");
                     }else if (bankCardNumberProve) {
                         Common.alert("银行卡材料信息附件必须上传");
                     }else{
                         industrialTalentsApi.addIndustrialTalents($('#addForm'),function(){
                             parent.window.dataReload();
                             Common.info("保存成功");
                             Lib.closeFrame();
                         });
                     }

                });
            });

            $("#addButton-PandD").click(function(){
                form.on('submit(form)', function(){
                    /**
                     * 获取身份证文件
                     */

                    var isEmpty = Common.fileRequire("#IdfileDataList");
                    var payList = Common.fileRequire("#payListDataList");
                    var taxProof = Common.fileRequire("#taxProofDataList");
                    var bankCardNumberProve = Common.fileRequire("#bankCardNumberProveDataList");
                    var otherMaterials = Common.fileRequire("#otherMaterialsDataList");

                    if(isEmpty){
                        Common.alert("身份证件附件必须上传");
                    }else if (payList) {
                        Common.alert("纳税清单附件必须上传");
                    }else if (taxProof) {
                        Common.alert("完税证明附件必须上传");
                    }else if (bankCardNumberProve) {
                        Common.alert("银行卡材料信息附件必须上传");
                    }else {
                        Common.openConfirm("确认申报?", function () {
                            industrialTalentsApi.personnel($('#addForm'), function () {
                                parent.window.dataReload();
                                Common.info("保存并申报成功");
                                Lib.closeFrame();
                            });
                        }, null)
                    }
                });
            });
        
            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
                // Lib.innerDeleteTab();
            });
        }
    			
    }
    exports('add',view);
});